package com.GB26875_3_2011.config;

import com.GB26875_3_2011.common.GB26875Constant;
import io.netty.handler.logging.LogLevel;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.concurrent.TimeUnit;

/**
 * @author 蒋仕国
 * @projectName GB26875_3_211
 * @ClassName ServerProperties
 * @date 2025-01-10 15:26
 * @Description: TODO []
 */
@ConfigurationProperties(prefix = "gb26875")
@Data
public class GB26875Properties {

    /**
     * serverIp
     */
    private String serverIp = "127.0.0.1";

    /**
     * serverPort
     */
    private Integer serverPort = 8751;

    /**
     * serverType
     */
    private ServerType serverType = ServerType.TCP;

    /**
     * boss线程数量
     */
    private Integer bossThreads = 1;

    /**
     * worker 线程数量
     */
    private Integer workerThreads = 5;

    /**
     * 业务线程池数量
     */
    private Integer businessThreads = 10;

    /**
     * SO_BACKLOG，未连接+已连接队列和的最大长度，超过长度后请求会被拒绝
     */
    private int backlog = 1024;

    /**
     * LogLevel
     */
    private LogLevel logLevel = LogLevel.INFO;

    /**
     * 连接保持
     */
    private boolean keepAlive = true;

    /**
     * 报文开始符号
     */
    private byte[] startFlag = GB26875Constant.MESSAGE_START_FLAG;

    /**
     * 报文结束符号
     */
    private byte[] endFlag = GB26875Constant.MESSAGE_END_FLAG;

    /**
     * 本机地址Hex 【由平台发放】
     */
    private String localAddressHex = "385B01000000";

    /**
     * protocol 版本
     */
    private String protocolVersion = "0101";


    /**
     * 读超时时间
     */
    private Integer readTimeout = 600;

    /**
     *  写超时时间
     */
    private Integer writeTimeout = 600;

    /**
     * 所有操作超时时间
     */
    private Integer allTimeout = 600;

    /**
     * 时间单位
     */
    private TimeUnit timeoutUnit = TimeUnit.SECONDS;

    public static enum ServerType {
        TCP, UDP;

    }

}
